//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.example.controller;

import com.example.common.Result;
import com.example.entity.Recruitmentapplication;
import com.example.service.RecruitmentapplicationService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping({"/recruitmentapplication"})
public class RecruitmentapplicationController {
    @Resource
    private RecruitmentapplicationService recruitmentapplicationService;

    public RecruitmentapplicationController() {
    }

    @GetMapping({"/selectByRecruitmentId"})
    public Result selectAll(@RequestParam Integer recruitmentId) {
        List<Recruitmentapplication> list = this.recruitmentapplicationService.selectByRecruitmentId(recruitmentId);
        return Result.success(list);
    }

    @GetMapping({"/selectById/{id}"})
    public Result selectById(@PathVariable Integer id, @PathVariable String no) {
        Recruitmentapplication recruitmentapplication = this.recruitmentapplicationService.selectById(id);
        return Result.success(recruitmentapplication);
    }

    @GetMapping({"/selectByOne"})
    public Result selectByOne(@RequestParam Integer id, @RequestParam(required = false) String no) {
        Recruitmentapplication recruitmentapplication = this.recruitmentapplicationService.selectById(id);
        return Result.success(recruitmentapplication);
    }

    @GetMapping({"/selectList"})
    public Result selectList(Recruitmentapplication recruitmentapplication) {
        List<Recruitmentapplication> list = this.recruitmentapplicationService.selectList(recruitmentapplication);
        return Result.success(list);
    }

    @GetMapping({"/selectPage"})
    public Result selectPage(Recruitmentapplication recruitmentapplication, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize) {
        PageInfo<Recruitmentapplication> pageInfo = this.recruitmentapplicationService.selectPage(recruitmentapplication, pageNum, pageSize);
        return Result.success(pageInfo);
    }

    @PostMapping({"/add"})
    public Result add(@RequestBody Recruitmentapplication recruitmentapplication) {
        this.recruitmentapplicationService.add(recruitmentapplication);
        return Result.success();
    }

    @PutMapping({"/updateById"})
    public Result updateById(@RequestBody Recruitmentapplication recruitmentapplication) {
        this.recruitmentapplicationService.updateById(recruitmentapplication);
        return Result.success();
    }

    @DeleteMapping({"/deleteById/{id}"})
    public Result deleteById(@PathVariable Integer id) {
        this.recruitmentapplicationService.deleteById(id);
        return Result.success();
    }

    @DeleteMapping({"/deleteBatch"})
    public Result deleteBatch(@RequestBody List<Integer> ids) {
        this.recruitmentapplicationService.deleteBatch(ids);
        return Result.success();
    }

    @GetMapping({"/selectByStudentId"})
    public Result selectByStudentId(@RequestParam Integer studentId) {
        Recruitmentapplication query = new Recruitmentapplication();
        query.setStudentId(studentId);
        List<Recruitmentapplication> list = this.recruitmentapplicationService.selectAll(query);
        return Result.success(list);
    }

    /**
     * 提交招募申请
     * @param recruitmentapplication
     * @return
     */
    @GetMapping({"/submitReCruitmentApplication"})
    public Result submitReCruitmentApplication(Recruitmentapplication recruitmentapplication) {
        recruitmentapplicationService.add(recruitmentapplication);
        return Result.success();
    }
}
